
export default {
    mounted(el) {
        const oMenuItem = el.querySelector('.menu-item')
        const oTreeMenu = el.querySelector('.tree-menu')
        const oIcon = el.querySelector('span')

        if(oTreeMenu) {
            oMenuItem.addEventListener('click', () => {
                if(oTreeMenu.style.display === 'none') {
                    oTreeMenu.style.display = 'block'
                    oIcon.className = "iconfont icon-xiangxia"
                } else {
                    oTreeMenu.style.display = 'none'
                    oIcon.className = "iconfont icon-xiangyou"
                }
            }, false)
        }

        oMenuItem.addEventListener('mouseenter', () => {
            oMenuItem.style.backgroundColor = '#fafafa'
        }, false)
        oMenuItem.addEventListener('mouseleave', () => {
            oMenuItem.style.backgroundColor = 'transparent'
        }, false)
    }
}